<?php

/**
 * Helper Class
 *
 * @author Rezan Achmad
 */
class Util {

    /**
     * Convert date from dd/mm/yy format to yy-mm-dd format.
     * 
     * Example :
     * 15/06/2011 convert to 2011-06-15
     * 
     * @param string $value date with format dd/mm/yy
     * @return string return formated date yy-mm-dd if $value is valid, otherwise return
     *  $value.
     */
    public static function convertDate($value) {
        $explode = explode('/', $value);
        if (count($explode) == 3) {
            $newDate = $explode[2] . "-" . $explode[1] . "-" . $explode[0];
            return $newDate;
        } else {
            return $value;
        }
    }

}

?>
